import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/list_item.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class CheckpointListViewWidget extends StatelessWidget {
  const CheckpointListViewWidget({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(converter: (store) {
      return AppStateViewModel(state: store.state);
    }, builder: (context, vm) {
      var dungeons = vm.state.yeXiuState.checkpointState.checkpointDungeons;
      return ListView.separated(
          itemCount: dungeons?.dungeonList?.length ?? 0,
          separatorBuilder: (context, index) {
            return SizedBox(
              height: setRatio(20),
            );
          },
          itemBuilder: (context, index) {
            return Column(
              children: <Widget>[
                CheckpointItemWidget(
                  index: index,
                  data: dungeons?.dungeonList[index]
                ),
                index == (dungeons?.dungeonList?.length ?? 0 - 1)
                    ? SizedBox(
                        height: setRatio(20),
                      )
                    : Container()
              ],
            );
          });
    });
  }
}
